<?php $season = Doctrine::getTable('BbSeason')->findOneBySId($seasonId); ?>
<?php $league = Doctrine::getTable('BbLeague')->findOneById($season->getLId())?>
<?php
         $statsbypts = Doctrine::getTable('BbPlayerStat')->getAvgStatsBySeason($seasonId, 'pts', 'des')
?>
<?php ini_set("precision","3"); ?>
<?php
         $statsbyfg = Doctrine::getTable('BbPlayerStat')->getAvgStatsBySeason($seasonId, 'fg', 'des')
?>
<?php
         $statsbyast = Doctrine::getTable('BbPlayerStat')->getAvgStatsBySeason($seasonId,  'ast', 'des')
?>
<?php
         $statsbyreb = Doctrine::getTable('BbPlayerStat')->getAvgStatsBySeason($seasonId, 'reb', 'des')
?>
<?php
         $statsbyblk = Doctrine::getTable('BbPlayerStat')->getAvgStatsBySeason($seasonId,  'blk', 'des')
?>
<?php
         $statsbystl = Doctrine::getTable('BbPlayerStat')->getAvgStatsBySeason($seasonId,  'stl', 'des')
?>

<div class="column-left">
<div class="news-title"><?php echo $league." :: ".$season ?></div>	
<div class="span-2">
   <div class="mod-container mod-table mod-no-footer">
   		<div class="mod-header stathead"><h4>Довтолгоогоор тэргүүлэгчид</h4></div>
   		<div class="mod-content">
   		<table cellspacing="1" cellpadding="3" class="tablehead">
			<tbody>
				<tr class="colhead">
					<td colspan="2">ОНОО</td>
					<td align="right">PPG</td>
				</tr>
				<?php $odd=1; for($i = 0; $i < 5; ++$i) { ?>
					<?php $player = Doctrine::getTable('BbPlayers')->findOneById($statsbypts[$i]['playerId']); ?>
	             	<?php $team = Doctrine::getTable('BbTeams')->findOneById($player->getTeamId()); ?>
					<tr class="<?php if($odd==1) { echo 'odd'; $odd=0; } else { echo 'even'; $odd=1; }?>">
						<?php if($i==0) echo 
							'<td align="center" style="background: none; border: 0;" rowspan="5">'.
								image_tag("/uploads/player/".$player->getDefImg(), array('alt'=>$player, 'style'=>'max-width:70px;max-height:100px;float:left;padding:1px;border:1px solid #eee;')) 
							.'<br>
							<a href="/player/show?seasonId='.$seasonId.'&nick='.$player->getNick().'">'.$player->getFullName().'</a>
							</td>'; ?>
						<td>
							<?php echo ($i+1).'.&nbsp;<a href="/player/show?seasonId='.$seasonId.'&nick='.$player->getNick().'">'.$player->getFullName().'</a>,'.$team->getTAbrname(); ?>
						</td>
						<td align="right"><?php echo $statsbypts[$i]['pts'] ?></td>
					</tr>
				<?php  }?>
				<tr class="even">
					<td align="center" colspan="3"><a href="<?php echo url_for('stats/index?seasonId='.$seasonId.'&orderByColumn=pts&order=desc')?>" class="bi">Бүрэн Хүснэгт</a></td>
				</tr>			
</tbody></table>
</div>
<div class="mod-content">
   		<table cellspacing="1" cellpadding="3" class="tablehead">
			<tbody>
					<tr class="colhead">
						<td colspan="2">ДАМЖУУЛАЛТ</td>
						<td align="right">APG</td>
					</tr>
				<?php $odd=1; for($i = 0; $i < 5; ++$i) { ?>
					<?php $player = Doctrine::getTable('BbPlayers')->findOneById($statsbyast[$i]['playerId']); ?>
	             	<?php $team = Doctrine::getTable('BbTeams')->findOneById($player->getTeamId()); ?>
					<tr class="<?php if($odd==1) { echo 'odd'; $odd=0; } else { echo 'even'; $odd=1; }?>">
						<?php if($i==0) echo 
							'<td align="center" style="background: none; border: 0;" rowspan="5">'.
								image_tag("/uploads/player/".$player->getDefImg(), array('alt'=>$player, 'style'=>'max-width:70px;max-height:100px;float:left;padding:1px;border:1px solid #eee;')) 
							.'</br>
							<a href="/player/show?seasonId='.$seasonId.'&nick='.$player->getNick().'">'.$player->getFullName().'</a>
							</td>'; ?>
						<td>
							<?php echo ($i+1).'.&nbsp;<a href="/player/show?seasonId='.$seasonId.'&nick='.$player->getNick().'">'.$player->getFullName().'</a>,'.$team->getTAbrname(); ?>
						</td>
						<td align="right"><?php echo $statsbyast[$i]['ast'] ?></td>
					</tr>
				<?php  }?>
				<tr class="even">
					<td align="center" colspan="3"><a href="<?php echo url_for('stats/index?seasonId='.$seasonId.'&orderByColumn=ast&order=desc')?>" class="bi">Бүрэн Хүснэгт</a></td>
				</tr>
		   </tbody>
	   </table>
</div>

<div class="mod-content">
   		<table cellspacing="1" cellpadding="3" class="tablehead">
			<tbody>
				<tr class="colhead">
					<td colspan="2">Довтолгооны Хувиар</td>
					<td align="right">FGPG</td>
				</tr>
				<?php $odd=1; for($i = 0; $i < 5; ++$i) { ?>
					<?php $player = Doctrine::getTable('BbPlayers')->findOneById($statsbyast[$i]['playerId']); ?>
	             	<?php $team = Doctrine::getTable('BbTeams')->findOneById($player->getTeamId()); ?>
					<tr class="<?php if($odd==1) { echo 'odd'; $odd=0; } else { echo 'even'; $odd=1; }?>">
						<?php if($i==0) echo 
							'<td align="center" style="background: none; border: 0;" rowspan="5">'.
								image_tag("/uploads/player/".$player->getDefImg(), array('alt'=>$player, 'style'=>'max-width:70px;max-height:100px;float:left;padding:1px;border:1px solid #eee;')) 
							.'<br>
							<a href="/player/show?seasonId='.$seasonId.'&nick='.$player->getNick().'">'.$player->getFullName().'</a>
							</td>'; ?>
						<td>
							<?php echo ($i+1).'.&nbsp;<a href="/player/show?seasonId='.$seasonId.'&nick='.$player->getNick().'">'.$player->getFullName().'</a>,'.$team->getTAbrname(); ?>
						</td>
						<td align="right"><?php echo $statsbyfg[$i]['fg'] ?></td>
					</tr>
				<?php  }?>
				<tr class="even">
					<td align="center" colspan="3"><a href="<?php echo url_for('stats/index?seasonId='.$seasonId.'&orderByColumn=fg&order=desc')?>" class="bi">Бүрэн Хүснэгт</a></td>
				</tr>
</tbody></table>
</div>
</div>
</div>

<div class="span-2 last">
   <div class="mod-container mod-table mod-no-footer">
   		<div class="mod-header stathead"><h4>Хамгаалалтаар тэргүүлэгчид</h4></div>
   		<div class="mod-content">
   		<table cellspacing="1" cellpadding="3" class="tablehead">
			<tbody>
				<tr class="colhead">
					<td colspan="2">Самбараас Бөмөг Авалт</td>
					<td align="right">RPG</td>
				</tr>
				<?php $odd=1; for($i = 0; $i < 5; ++$i) { ?>
					<?php $player = Doctrine::getTable('BbPlayers')->findOneById($statsbyreb[$i]['playerId']); ?>
	             	<?php $team = Doctrine::getTable('BbTeams')->findOneById($player->getTeamId()); ?>
					<tr class="<?php if($odd==1) { echo 'odd'; $odd=0; } else { echo 'even'; $odd=1; }?>">
						<?php if($i==0) echo 
							'<td align="center" style="background: none; border: 0;" rowspan="5">'.
								image_tag("/uploads/player/".$player->getDefImg(), array('alt'=>$player, 'style'=>'max-width:70px;max-height:100px;float:left;padding:1px;border:1px solid #eee;')) 
							.'<br>
							<a href="/player/show?seasonId='.$seasonId.'&nick='.$player->getNick().'">'.$player->getFullName().'</a>
							</td>'; ?>
						<td>
							<?php echo ($i+1).'.&nbsp;<a href="/player/show?seasonId='.$seasonId.'&nick='.$player->getNick().'">'.$player->getFullName().'</a>,'.$team->getTAbrname(); ?>
						</td>
						<td align="right"><?php echo $statsbyreb[$i]['reb'] ?></td>
					</tr>
				<?php  }?>
				<tr class="even">
					<td align="center" colspan="3"><a href="<?php echo url_for('stats/index?seasonId='.$seasonId.'&orderByColumn=reb&order=desc')?>" class="bi">Бүрэн Хүснэгт</a></td>
				</tr>
</tbody></table>
</div>
<div class="mod-content">
   		<table cellspacing="1" cellpadding="3" class="tablehead">
			<tbody>
				<tr class="colhead">
					<td colspan="2">Блок</td>
					<td align="right">BPG</td>
				</tr>
				<?php $odd=1; for($i = 0; $i < 5; ++$i) { ?>
					<?php $player = Doctrine::getTable('BbPlayers')->findOneById($statsbyblk[$i]['playerId']); ?>
	             	<?php $team = Doctrine::getTable('BbTeams')->findOneById($player->getTeamId()); ?>
					<tr class="<?php if($odd==1) { echo 'odd'; $odd=0; } else { echo 'even'; $odd=1; }?>">
						<?php if($i==0) echo 
							'<td align="center" style="background: none; border: 0;" rowspan="5">'.
								image_tag("/uploads/player/".$player->getDefImg(), array('alt'=>$player, 'style'=>'max-width:70px;max-height:100px;float:left;padding:1px;border:1px solid #eee;')) 
							.'<br>
							<a href="/player/show?seasonId='.$seasonId.'&nick='.$player->getNick().'">'.$player->getFullName().'</a>
							</td>'; ?>
						<td>
							<?php echo ($i+1).'.&nbsp;<a href="/player/show?seasonId='.$seasonId.'&nick='.$player->getNick().'">'.$player->getFullName().'</a>,'.$team->getTAbrname(); ?>
						</td>
						<td align="right"><?php echo $statsbyblk[$i]['blk'] ?></td>
					</tr>
				<?php  }?>
				<tr class="even">
					<td align="center" colspan="3"><a href="<?php echo url_for('stats/index?seasonId='.$seasonId.'&orderByColumn=blk&order=desc')?>" class="bi">Бүрэн Хүснэгт</a></td>
				</tr>
</tbody></table>
</div>
<div class="mod-content">
   		<table cellspacing="1" cellpadding="3" class="tablehead">
			<tbody>
				<tr class="colhead">
					<td colspan="2">Бөмбөг Таслалт</td>
					<td align="right">SPG</td>
				</tr>
				<?php $odd=1; for($i = 0; $i < 5; ++$i) { ?>
					<?php $player = Doctrine::getTable('BbPlayers')->findOneById($statsbystl[$i]['playerId']); ?>
	             	<?php $team = Doctrine::getTable('BbTeams')->findOneById($player->getTeamId()); ?>
					<tr class="<?php if($odd==1) { echo 'odd'; $odd=0; } else { echo 'even'; $odd=1; }?>">
						<?php if($i==0) echo 
							'<td align="center" style="background: none; border: 0;" rowspan="5">'.
								image_tag("/uploads/player/".$player->getDefImg(), array('alt'=>$player, 'style'=>'max-width:70px;max-height:100px;float:left;padding:1px;border:1px solid #eee;')) 
							.'<br>
							<a href="/player/show?seasonId='.$seasonId.'&nick='.$player->getNick().'">'.$player->getFullName().'</a>
							</td>'; ?>
						<td>
							<?php echo ($i+1).'.&nbsp;<a href="/player/show?seasonId='.$seasonId.'&nick='.$player->getNick().'">'.$player->getFullName().'</a>,'.$team->getTAbrname(); ?>
						</td>
						<td align="right"><?php echo $statsbystl[$i]['stl'] ?></td>
					</tr>
				<?php  }?>
				<tr class="even">
					<td align="center" colspan="3"><a href="<?php echo url_for('stats/index?seasonId='.$seasonId.'&orderByColumn=stl&order=desc')?>" class="bi">Бүрэн Хүснэгт</a></td>
				</tr>
</tbody></table>
</div>
</div>
</div>
</div>

<?php include_partial('main/right', array());?>

<br clear="all">

